package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

@Getter@Setter
public class Region extends BaseDomain{
    //普通
    public static final Integer STATE_NORMAL = 0;
    //推荐
    public static final Integer STATE_COMMEND = 1;
    //禁用
    public static final Integer STATE_DISABLED = -1;

    private String name;

    private Region parent;

    private Integer state = STATE_NORMAL;

    public Map<String,Object> toTreeMap(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("text",name);
        map.put("lazyLoad",true);

        if (state == STATE_COMMEND) {
            map.put("tags",new String[]{"推荐"});
        }
        return map;
    }

    public String getJson(){
        Map<String,Object> map = new HashMap<>();
        map.put("id",id);
        map.put("name",name);
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

}